<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>获取按指定宽度截断的字符串</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.mb-strcut.html">mb_strcut</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.mb-stripos.html">mb_stripos</a></div>
 <div class="up"><a href="ref.mbstring.html">多字节字符串 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.mb-strimwidth" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">mb_strimwidth</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.6, PHP 5)</p><p class="refpurpose"><span class="refname">mb_strimwidth</span> &mdash; <span class="dc-title">获取按指定宽度截断的字符串</span></p>

 </div>
   
 <div class="refsect1 description" id="refsect1-function.mb-strimwidth-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">string</span> <span class="methodname"><strong>mb_strimwidth</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$str</code></span>
   , <span class="methodparam"><span class="type">int</span> <code class="parameter">$start</code></span>
   , <span class="methodparam"><span class="type">int</span> <code class="parameter">$width</code></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$trimmarker</code></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$encoding</code></span>
  ]] )</div>

  <p class="para rdfs-comment">
   按 <em><code class="parameter">width</code></em> 将<span class="type"><span class="type 字符串">字符串</span></span> <em><code class="parameter">str</code></em> 截短。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.mb-strimwidth-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">str</code></em></dt>

     <dd>

      <p class="para">
       要截短的 <span class="type"><a href="language.types.string.html" class="type string">string</a></span>。
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">start</code></em></dt>

     <dd>

      <p class="para">
       开始位置的偏移。从这些字符数开始的截取字符串。（默认是 0 个字符）
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">width</code></em></dt>

     <dd>

      <p class="para">
       所需修剪的宽度。
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">trimmarker</code></em></dt>

     <dd>

      <p class="para">
       当字符串被截短的时候，将此字符串添加到截短后的末尾。
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">encoding</code></em></dt>

     <dd>

      <p class="para"><em><code class="parameter">encoding</code></em>
参数为字符编码。如果省略，则使用内部字符编码。</p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.mb-strimwidth-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   截短后的 <span class="type"><a href="language.types.string.html" class="type string">string</a></span>。
   如果设置了 <em><code class="parameter">trimmarker</code></em>，还会将 <em><code class="parameter">trimmarker</code></em> 追加到返回的值。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.mb-strimwidth-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-2653">
    <p><strong>Example #1 <span class="function"><strong>mb_strimwidth()</strong></span> 例子</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">mb_strimwidth</span><span style="color: #007700">(</span><span style="color: #DD0000">"Hello&nbsp;World"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">10</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"..."</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">//&nbsp;输出&nbsp;Hello&nbsp;W...<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.mb-strimwidth-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.mb-strwidth.html" class="function" rel="rdfs-seeAlso">mb_strwidth()</a> - 返回字符串的宽度</span></li>
    <li class="member"><span class="function"><a href="function.mb-internal-encoding.html" class="function" rel="rdfs-seeAlso">mb_internal_encoding()</a> - 设置/获取内部字符编码</span></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.mb-strcut.html">mb_strcut</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.mb-stripos.html">mb_stripos</a></div>
 <div class="up"><a href="ref.mbstring.html">多字节字符串 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
